vcServoController

vcServoController is a controller for driving independent joints. The controller itself only supports forward kinematics and cannot be used in robots rather with them. For example, a servo controller can be used for external axis systems, grippers, fixtures, weld guns, and other simple mechanical structures.

See in: Overview

Module: vcRobotics

Parent: vcBehavior

Children: vcRobotController

Referenced by: vcDof.Controller, vcJoint.Controller, vcJoint.ExternalController, vcSimJointExportField.Controller

Properties

Learn how to use properties here. The properties are also inherited from the parent class.

NameTypeAccessDescription
FlangeNodevcNodeRWDefines the flange node of servo, for example the mount plate or carriage for other kinematic structures.
HeartbeatTimeRealRWIf UseHeartbeat is set to True, defines the interval or pulse for updating joints.
JointCountIntegerRGets the number of joints in servo.
JointsvcList[vcJoint]RGets a list of all joints referenced by servo.
RootNodevcNodeRWDefines the root node of servo, thereby the fixed base of kinematic structure.
SpeedRealRWDefines joint speed as a percentage of maximum speed for driving joints in range 0 to 100.
UseHeartbeatBooleanRWTurns on/off the use of a heartbeat or pulse to drive and update joints.

Methods

Learn how to use methods here. The methods are also inherited from the parent class.

NameReturn TypeParametersDescription
calcMotionTimeRealNoneReturns the calculated motion time of servo using current joint values and listed targets.

Returns:
Real: motion time.
findJointvcJointString joint_nameReturns the first joint matching a given name in servo; otherwise returns None.
See more
Parameters:
joint_name (String): joint name

Returns:
vcJoint: joint found or None
getJointvcJointInteger joint_indexReturns the first joint matching a given name in servo; otherwise returns None.
See more
Parameters:
joint_name (String): joint name

Returns:
vcJoint: joint found or None
getJointTargetRealInteger joint_indexReturns the target value of a joint at a given index in servo.
See more
Parameters:
joint_index (Integer): index

Returns:
Real: target value of a joint
getJointValueRealInteger joint_indexReturns the current value of a joint at a given index in servo.
See more
Parameters:
joint_index (Integer): index

Returns:
Real: current value of a joint
movevcTasklist jvaluesDrives all joints in servo to target values, and then returns the actual motion time.
See more
Target values for each joint in servo can be given as separate, optional arguments.

Parameters:
([Real joint_0, ... Real joint_n]): joint values
(): No arguments

Returns:
Real: actual motion time
movevcTaskNone-
moveImmediateNoneList[Real] valuesDrives all joints in servo to target values in zero simulation time.
See more
Target values for each joint in servo can be given as separate, optional arguments.

Parameters:
[Real joint_0, ... Real joint_n]: joint values
moveJointvcTaskInteger index,
Real value
Moves a joint at a given index in servo to a given value, and then returns the actual motion time.
See more
Parameters:
joint_index (Integer): index
joint_value (Real): joint value

Returns:
Real: actual motion time
setJointTargetNoneInteger joint_index,
Real joint_value
Sets the target value of a joint at a given index in servo to a given value.

Parameters:
joint_index (Integer): index
joint_value (Real): joint value
setMotionTimeNoneReal timeForces the servo to execute joint movements at a given motion time.

Parameters:
time (Real): motion time

Events

Learn how to use events here. The events are also inherited from the parent class.

NameParametersDescription
OnHeartbeatNoneTriggered when a pulse or heartbeat is generated by servo.
See more
Note: This event handler can be used by a vcRobotController object executing a vcProcessStatement object in robot program.

Parameters:
servo (vcServoController)
event_type (vcController)

Example: Drive Servo One Axis

""" This example shows how to set a target position for a servo joint and drive the servo to the target value."""

import vcCore as vc

async def OnRun():
  comp = vc.getComponent()
  servo_x = comp.findBehavior("ServoX")
  joint_index = 0
  x_target = 100
  servo_x.setJointTarget(joint_index,x_target)  
  await servo_x.move()

Example: Drive Multiple Servos Asynchronously

""" This example shows how to control servos asynchronously by using the vcServoController behavior.  """

import vcCore as vc

async def OnRun():
  comp = vc.getComponent()
  servo_x = comp.findBehavior("ServoX")
  servo_y = comp.findBehavior("ServoY")
  servo_z = comp.findBehavior("ServoZ")
  joint_index = 0
  x_target = 100
  y_target = 100
  z_target = 100
  servo_x.setJointTarget(joint_index,x_target)
  servo_y.setJointTarget(joint_index,y_target)
  servo_z.setJointTarget(joint_index,z_target)

  # start asynchronous motions 
  x_motion = servo_x.move() # returns an awaitable task
  y_motion = servo_y.move()
  z_motion = servo_z.move()

  # wait until all motions are completed
  await vc.allTasks([x_motion,y_motion,z_motion]) # waits for all tasks to complete
  print("All servos have reached their target positions.")